#include "fsm_switch.h"
#include <iostream>

void Switch::state_on_entry() {
    std::cout << fsm_instance_name << " enter state on" << std::endl;
}

void Switch::state_on_exit() {
    std::cout << fsm_instance_name << " exit  state on" << std::endl;
}

void Switch::state_off_entry() {
    std::cout << fsm_instance_name << " enter state off" << std::endl;
}

void Switch::state_off_exit() {
    std::cout << fsm_instance_name << " exit  state off" << std::endl;
}


void Switch::start() {
    state_on.name = "state_on";
    state_on.entry = [this]{state_on_entry();};
    state_on.exit = [this]{state_on_exit();};
    state_on.events[toggle] = [this]{transit(state_off);};
    
    state_off.name = "state_off";
    state_off.entry = [this]{state_off_entry();};
    state_off.exit = [this]{state_off_exit();};
    state_off.events[toggle] = [this]{transit(state_on);};
    

    enter_initial_state();
}